]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
grabHelper: Fix regression for dwelling with mouse down
authorJasper St. Pierre <jstpierre@mecheye.net>
Wed, 19 Sep 2012 02:04:57 +0000 (23:04 -0300)
committerJasper St. Pierre <jstpierre@mecheye.net>
Wed, 19 Sep 2012 11:10:12 +0000 (08:10 -0300)
b203a95a786af60257e55881c19b45192a0655b8 introduced a regression
where we forgot to bail out if the pushModal didn't succeed properly.

https://bugzilla.gnome.org/show_bug.cgi?id=684344

js/ui/grabHelper.js

index 0387b80e790c8742dec388c8dbe550e738535fce..fccc2fb4da0c0c627ca34b2278cfe7b06f5bc024 100644 (file)
@@ -148,31 +148,32 @@ const GrabHelper = new Lang.Class({
             return true;
 
         params.savedFocus = focus;
-        this._grabStack.push(params);
 
-        if (params.modal)
-            this._takeModalGrab();
+        if (params.modal && !this._takeModalGrab())
+            return false;
 
-        if (params.grabFocus)
-            this._takeFocusGrab(hadFocus);
+        if (params.grabFocus && !this._takeFocusGrab(hadFocus))
+            return false;
 
         if (hadFocus || params.grabFocus)
             _navigateActor(newFocus);
 
+        this._grabStack.push(params);
         return true;
     },
 
     _takeModalGrab: function() {
         let firstGrab = (this._modalCount == 0);
-        this._modalCount++;
-        if (!firstGrab)
-            return;
+        if (firstGrab) {
+            if (!Main.pushModal(this._owner))
+                return false;
 
-        if (!Main.pushModal(this._owner))
-            return;
+            this._capturedEventId = global.stage.connect('captured-event', Lang.bind(this, this._onCapturedEvent));
+            this._eventId = global.stage.connect('event', Lang.bind(this, this._onEvent));
+        }
 
-        this._capturedEventId = global.stage.connect('captured-event', Lang.bind(this, this._onCapturedEvent));
-        this._eventId = global.stage.connect('event', Lang.bind(this, this._onEvent));
+        this._modalCount++;
+        return true;
     },
 
     _releaseModalGrab: function() {
@@ -196,23 +197,24 @@ const GrabHelper = new Lang.Class({
 
     _takeFocusGrab: function(hadFocus) {
         let firstGrab = (this._grabFocusCount == 0);
-        this._grabFocusCount++;
-        if (!firstGrab)
-            return;
+        if (firstGrab) {
+            let metaDisplay = global.screen.get_display();
 
-        let metaDisplay = global.screen.get_display();
+            this._grabbedFromKeynav = hadFocus;
+            this._preGrabInputMode = global.stage_input_mode;
+            this._prevFocusedWindow = metaDisplay.focus_window;
 
-        this._grabbedFromKeynav = hadFocus;
-        this._preGrabInputMode = global.stage_input_mode;
-        this._prevFocusedWindow = metaDisplay.focus_window;
+            if (this._preGrabInputMode == Shell.StageInputMode.NONREACTIVE ||
+                this._preGrabInputMode == Shell.StageInputMode.NORMAL) {
+                global.set_stage_input_mode(Shell.StageInputMode.FOCUSED);
+            }
 
-        if (this._preGrabInputMode == Shell.StageInputMode.NONREACTIVE ||
-            this._preGrabInputMode == Shell.StageInputMode.NORMAL) {
-            global.set_stage_input_mode(Shell.StageInputMode.FOCUSED);
+            this._keyFocusNotifyId = global.stage.connect('notify::key-focus', Lang.bind(this, this._onKeyFocusChanged));
+            this._focusWindowChangedId = metaDisplay.connect('notify::focus-window', Lang.bind(this, this._focusWindowChanged));
         }
 
-        this._keyFocusNotifyId = global.stage.connect('notify::key-focus', Lang.bind(this, this._onKeyFocusChanged));
-        this._focusWindowChangedId = metaDisplay.connect('notify::focus-window', Lang.bind(this, this._focusWindowChanged));
+        this._grabFocusCount++;
+        return true;
     },
 
     _releaseFocusGrab: function() {